One-Pass Video Stabilization

ABSTRACT

A method of stabilizing a video in real time using a single pass including receiving consecutive video frames, where the consecutive video frames include a current video frame and previous video frames, storing the consecutive video frames in a buffer, estimating a global motion for the current video frame by describing a camera&#39;s relative motion between the current video frame and one of the previous video frames adjacent to the current video frame, estimating a long-term camera motion for the current video frame by determining a geometric mean of an accumulation of the estimate of the global motion for the current video frame and an estimate of global motion for each of the previous video frames, and displaying the current video frame on a display of an electronic device, the current video frame stabilized based on the estimate of the long-term camera motion.

CROSS-REFERENCE TO RELATED APPLICATIONS

This patent application is a continuation of co-pending U.S. patentapplication Ser. No. 14/642,469, entitled “One-Pass VideoStabilization,” filed Mar. 9, 2015, which claims priority to U.S.Provisional Application No. 61/949,909, entitled “One-Pass VideoStabilization by Hybrid Model Localized Path Planning,” filed on Mar. 7,2014, and to U.S. Provisional Application No. 61/952,046, entitled“One-Pass, Low-Complexity Software-Based Video Stabilization Method,”filed on Mar. 12, 2014, which are hereby incorporated by reference intheir entirety.

STATEMENT REGARDING FEDERALLY SPONSORED RESEARCH OR DEVELOPMENT

Not applicable.

REFERENCE TO A MICROFICHE APPENDIX

Not applicable.

BACKGROUND

With the widespread prevalence of mobile devices, mobile video capturehas become an inseparable part of everyday lives. For many users, it ishard to hold a mobile camera steady, and consequently the capturedvideos are usually shaky. Thus, there is a need for robust real-timevideo stabilizers on mobile devices.

Conventional video stabilizers can be characterized as hardware-assistedsoftware-based approaches, and purely software-based approaches.

Hardware-assisted software-based approaches rely on knowledge about themobile device's camera (camera priors). For example, information aboutthe camera's dependent inter-frame delay, the intrinsic camera matrix,and the calibrated inertial sensors may be needed. However, due togyroscopic drift and sensor noises, camera translations computed fromthe mobile device's inertial sensors are prone to error, while theassumption of pure camera rotation is unrealistic for videos such asvideos of non-planar scenes. In addition, the requirement of dedicatedcalibration is impractical for some users.

Without knowledge or assumptions of camera priors, purely software-basedapproaches post-process a video in three main steps: (1) global motionestimation (GME), (2) camera path optimization, and (3) frame synthesis.In GME, the parametric camera motion between consecutive frames isestimated based on visual appearance. Camera path optimization isresponsible for removing unwanted vibration in camera motion whilepreserving intentional camera movement; an optimal intended smoothcamera trajectory is estimated and high-frequency fluctuations areremoved. In frame synthesis, a stabilized video is synthesized bywarping the original frames based on the estimated smooth trajectory.Earlier work applied low-pass filters to remove high-frequency motion.Recently, an L1-norm optimization has been used to generate a camerapath that follows cinematography rules.

There are applications, such as video conferencing and videosurveillance, in which it is preferable for the video sequence to bestabilized during capture instead of post-processing it after capture.If the video stabilizer is supposed to show the processed videoon-the-fly, then the camera path optimization has to be done in astreaming manner. That is, the optimizer scans each input video frameonly once, which may be referred to as “one-pass” processing.

There are a number of difficulties associated with camera pathoptimization in video stabilization, and one-pass optimization inparticular. First, the output of GME is often noisy due to factorsincluding occlusion or the lack of feature points, etc., in the inputvideo. Such noises can affect the estimation of camera intentionalmotion, and thus impact the stabilization performance. Second, aone-pass camera path optimizer only has access to a local window ofvideo frames at a time, and it can only scan each frame once. Thus,compared to a multi-pass version, a one-pass optimizer does not have theglobal level information about the entire camera motion trajectory andtherefore has to rely on limited information about local motion toestimate intentional camera motion. Third, one-pass optimization isoften required for real-time applications running on mobile hardwareplatforms, where complexity and memory issues prevent the use ofeffective but complicated algorithms in video stabilization.

Conventional software-based approaches generally do not performsatisfactorily to stabilize videos in real time. Except for motionfiltering methods, conventional camera path planning approaches need tohave the whole camera trajectory estimated and therefore rely ontwo-pass processing. Second, in many cases, robust feature tracks cannotbe obtained due to rapid camera motion, occlusions, etc. High-qualityfeature matching such as those relying on SIFT/SURF (scale invariantfeature transform/speeded up robust features) matching are not realisticfor mobile devices because of the devices' limited memory andcomputational power. For the same reason, methods that rely on extramotion editing (e.g., inpainting) or expensive optimization are notsuitable for real-time processing of videos, particularly highdefinition videos. Third, conventional real-time motion filteringmethods utilize scene-dependent parameter tuning. For example,aggressive filtering provides a more stabilized camera path but largerout-of-bound areas, while mild filtering provides less stabilization buta larger output. Many users do not have the knowledge or interest insuch parameter tuning, and would prefer automatic settings that producethe highest quality for stabilization.

SUMMARY

In an embodiment, the disclosure includes a device configured to provideone-pass, real-time video stabilization. The device includes a memoryincluding a buffer and instructions, and a processor coupled to thememory, the processor configured to execute the instructions stored inthe memory to cause the processor to store consecutive video frames inthe buffer of the memory after receipt, the consecutive video framesincluding a current video frame and previous video frames, estimate aglobal motion for the current video frame by describing a camera'srelative motion between the current video frame and one of the previousvideo frames adjacent to the current video frame, estimate a long-termcamera motion for the current video frame by determining a geometricmean of an accumulation of the estimated global motion for the currentvideo frame and an estimate of global motion for each of the previousvideo frames, and stabilize the current video frame based on theestimated long-term camera motion, and a display device coupled to theprocessor, the display device configured to display the current videoframe as stabilized.

In an embodiment, the disclosure includes a method of stabilizing avideo in real time using a single pass including receiving consecutivevideo frames, the consecutive video frames including a current videoframe and previous video frames, storing the consecutive video frames ina buffer, estimating a global motion for the current video frame bydescribing a camera's relative motion between the current video frameand one of the previous video frames adjacent to the current videoframe, estimating a long-term camera motion for the current video frameby determining a geometric mean of an accumulation of the estimatedglobal motion for the current video frame and an estimate of globalmotion for each of the previous video frames, and displaying the currentvideo frame on a display of an electronic device, the current videoframe stabilized based on the estimated long-term camera motion.

In an embodiment, the disclosure includes a computer program productcomprising computer executable instructions stored on a non-transitorymedium that when executed by a processor cause a one-pass, real-timevideo stabilization device to receive consecutive video frames, theconsecutive video frames including a current video frame and previousvideo frames, store the consecutive video frames in a buffer, estimate aglobal motion for the current video frame by describing a camera'srelative motion between the current video frame and one of the previousvideo frames adjacent to the current video frame, estimate a long-termcamera motion for the current video frame by determining a geometricmean of an accumulation of the estimated global motion for the currentvideo frame and an estimate of global motion for each of the previousvideo frames, and display the current video frame on a display of anelectronic device, the current video frame stabilized based on theestimated long-term camera motion.

BRIEF DESCRIPTION OF THE DRAWINGS

For a more complete understanding of this disclosure, reference is nowmade to the following brief description, taken in connection with theaccompanying drawings and detailed description, wherein like referencenumerals represent like parts.

FIG. 1 is a block diagram illustrating modules in an architecture of asoftware video stabilizer in embodiments according to the presentdisclosure.

FIG. 2 illustrates a sliding observation window that includes videoframes captured by a camera in embodiments according to the presentdisclosure.

FIGS. 3A and 3B illustrate an example of a drifting effect between twovideo frames, which is corrected in embodiments according to the presentdisclosure.

FIG. 4 is a flowchart of an example of a computer-implemented method forvideo stabilization in embodiments according to the present disclosure.

FIG. 5 is a diagram illustrating overall workflow in embodimentsaccording to the present disclosure.

FIG. 6 illustrates an example of warping a video frame in embodimentsaccording to the present disclosure.

FIG. 7 illustrates an example of the use of corrective transformationmatrices to warp video frames in embodiments according to the presentdisclosure.

FIG. 8 illustrates an example of a smoothed camera trajectory path inembodiments according to the present disclosure.

FIG. 9 is a flowchart of an example of a computer-implemented method forvideo stabilization in embodiments according to the present disclosure.

FIG. 10 is a flowchart of an example of a computer-implemented methodfor video stabilization in embodiments according to the presentdisclosure.

FIG. 11 is a flowchart of an example of a computer-implemented methodfor video stabilization in embodiments according to the presentdisclosure.

FIG. 12 is a block diagram of an example of a device capable ofimplementing embodiments according to the present disclosure.

DETAILED DESCRIPTION

It should be understood at the outset that although an illustrativeimplementation of one or more embodiments are provided below, thedisclosed systems and/or methods may be implemented using any number oftechniques, whether currently known or in existence. The disclosureshould in no way be limited to the illustrative implementations,drawings, and techniques illustrated below, including the exemplarydesigns and implementations illustrated and described herein, but may bemodified within the scope of the appended claims along with their fullscope of equivalents.

Reference will now be made in detail to the various embodiments of thepresent disclosure, examples of which are illustrated in theaccompanying drawings. While described in conjunction with theseembodiments, it will be understood that they are not intended to limitthe disclosure to these embodiments. On the contrary, the disclosure isintended to cover alternatives, modifications and equivalents, which maybe included within the spirit and scope of the disclosure as defined bythe appended claims. Furthermore, in the following detailed descriptionof the present disclosure, numerous specific details are set forth inorder to provide a thorough understanding of the present disclosure.However, it will be understood that the present disclosure may bepracticed without these specific details. In other instances, well-knownmethods, procedures, components, and circuits have not been described indetail so as not to unnecessarily obscure aspects of the presentdisclosure.

Some portions of the detailed descriptions that follow are presented interms of procedures, logic blocks, processing, and other symbolicrepresentations of operations on data bits within a computer memory.These descriptions and representations are the means used by thoseskilled in the data processing arts to most effectively convey thesubstance of their work to others skilled in the art. In the presentapplication, a procedure, logic block, process, or the like, isconceived to be a self-consistent sequence of steps or instructionsleading to a desired result. The steps are those utilizing physicalmanipulations of physical quantities. Usually, although not necessarily,these quantities take the form of electrical or magnetic signals capableof being stored, transferred, combined, compared, and otherwisemanipulated in a computer system. It has proven convenient at times,principally for reasons of common usage, to refer to these signals astransactions, bits, values, elements, symbols, characters, samples,pixels, or the like.

It should be borne in mind, however, that all of these and similar termsare to be associated with the appropriate physical quantities and aremerely convenient labels applied to these quantities. Unlessspecifically stated otherwise as apparent from the followingdiscussions, it is appreciated that throughout the present disclosure,discussions utilizing terms such as “maintaining,” “computing,”“performing,” “synthesizing,” “extracting,” “using”, “determining,”“testing,” “buffering,” “adjusting,” “applying,” “accessing,”“multiplying,” “modifying,” “generating,” “identifying,” “dividing,”“deriving,” “detecting,” or the like, refer to actions and processes(e.g., the operations of the flowcharts 400, 900, 1000, and 1100 ofFIGS. 4 and 9-11, respectively) of a computer system or device (e.g., asmartphone or tablet, such as the device 1200 of FIG. 12) or a similardevice or processor. A computer system or similar electronic computingdevice manipulates and transforms data represented as physical(electronic) quantities within the computer system memories, registersor other such information storage, transmission or display devices.

Embodiments described herein may be discussed in the general context ofcomputer-executable instructions residing on some form ofcomputer-readable storage medium, such as program modules, executed byone or more computers or other devices. By way of example, and notlimitation, computer-readable storage media may comprise non-transitorycomputer storage media and communication media. Generally, programmodules include routines, programs, objects, components, datastructures, etc., that perform particular tasks or implement particularabstract data types. The functionality of the program modules may becombined or distributed as desired in various embodiments.

Computer storage media includes volatile and nonvolatile, removable andnon-removable media implemented in any method or technology for storageof information such as computer-readable instructions, data structures,program modules or other data. Computer storage media includes, but isnot limited to, random access memory (RAM), read only memory (ROM),electrically erasable programmable ROM (EEPROM), flash memory or othermemory technology, compact disk ROM (CD-ROM), digital versatile disks(DVDs) or other optical storage, magnetic cassettes, magnetic tape,magnetic disk storage or other magnetic storage devices, or any othermedium that can be used to store the desired information and that canaccessed to retrieve that information.

Communication media can embody computer-executable instructions, datastructures, and program modules, and includes any information deliverymedia. By way of example, and not limitation, communication mediaincludes wired media such as a wired network or direct-wired connection,and wireless media such as acoustic, radio frequency (RF), infrared andother wireless media. Combinations of any of the above can also beincluded within the scope of computer-readable media.

Embodiments according to the present invention pertain to one-passreal-time video stabilization on mobile devices, such as but not limitedto smartphones, tablets, and wearable devices such as glasses andwatches.

In an embodiment, operations to stabilize a video include bufferingconsecutive original video frames captured using a camera, determiningtransformation matrices from subsets of the original video frames, wherethe transformation matrices represent estimates of stable camera motion,using the transformation matrices to warp the original video frames andgenerate stabilized video, and adjusting sizes of the subsets dependingon one or more conditions.

In one or more embodiments, global motion estimates that describe thecamera's relative motion between two consecutive video frames areaccessed. The geometric mean of the global motion estimates for each ofthe subsets is determined. Kalman filtering is applied to the geometricmean for each of the subsets to produce smoothed versions of thegeometric means. Parameters of the Kalman filtering are adjustedaccording to an indicator of reliability of the global motion estimates.The smoothed versions of the geometric means are multiplied to determinethe transformation matrices. Coefficients of the transformation matricesare modified to mitigate a drifting effect introduced by multiplying thesmoothed geometric means.

In one or more embodiments, a first transformation matrix for a firstsubset of the subsets is generated using a first motion model. The firstmotion model is selected from a plurality of motion models including ahomography model with eight degrees-of-freedom, an affine transformationmodel with five degrees-of-freedom, and a similarity transformationmodel with four degrees-of-freedom. Inter-frame transformation matricesbetween pairs of consecutive frames in the first subset are determined.Corrective transformation matrices that change the inter-frametransformation matrices to match the first transformation matrix arederived. The corrective transformation matrices are applied to theoriginal video frames in the first subset to determine a first set ofwarped video frames. A determination is made as to whether the first setof warped video frames satisfies one or more conditions. The conditionsinclude a constraint for out-of-bound area size and a constraint foramount of skewness of a warped video frame. If the first set of warpedvideo frames satisfies the condition(s), then a second transformationmatrix for a second subset of the subsets is generated using the firstmotion model; however, if the first set of warped video frames does notsatisfy the condition(s), then a determination is made as to whether thefirst subset can be divided into smaller subsets. If the first subsetcan be divided into smaller subsets, then it is divided into a secondsubset and a third subset, second and third transformation matrices aregenerated for the second and third subsets, respectively, using thefirst motion model, and the second and third transformation matrices areused to determine sets of warped video frames from original video framesin the second and third subsets, respectively. If, on the other hand,the first subset cannot be divided into smaller subsets, then a second(e.g., less complex) motion model is selected, a second transformationmatrix for the first subset is generated using the second motion model,and the second transformation matrix is used to determine the first setof warped video frames.

Embodiments according to the present disclosure provide onlineprocessing capability and better overall performance. Videostabilization is improved and artifacts are reduced. Visually pleasantvideos can be produced in real time according to cinematographic rules.The disclosed video stabilization methodologies can be implemented onmobile devices, such as smartphones, for example, without the usernecessarily having to perform scene-dependent parameter tuning.

One-Pass Video Stabilization—Kalman Filtering with Local MotionAdaptation

Embodiments about to be described pertain, in general, to a method forperforming one-pass camera path optimization for software videostabilization. In these embodiments, Kalman filtering is employed toestimate the long-term (intentional) camera path (e.g., due to panning,zooming, etc.), on-the-fly, from noisy global motion estimates based ona sliding observation window over incoming video frames. Furthermore, ametric is derived during global motion estimation (GME) to evaluate thereliability of each estimated global motion, and then is used in Kalmanfiltering to adjust the weight between an a priori estimate and ameasurement update. This practice can make the path optimizer morerobust to motion estimation errors and noises and help reduce thecomplexity of GME in video stabilization.

FIG. 1 is a block diagram illustrating modules in an architecture 100 ofa software video stabilizer in an embodiment according to the presentinvention. In the FIG. 1 embodiment, a camera path optimization module120 takes a series of global motion estimates {M_(i)} as input from aGME module 110. Each global motion estimate M_(i) takes the form of a3×3 transformation matrix and describes a camera's relative motionbetween frame i and frame i+1. Additionally, each {M_(i)} containsunwanted camera vibration and can be noisy. The output of the pathoptimization module 120 is a smoothed camera path {{tilde over(M)}_(i)}, which is used by the following frame synthesis module 130 tospatially realign frames.

To realize online video stabilization, a sliding observation window isset up to estimate local long-term camera motion, as shown in FIG. 2. InFIG. 2, a set of consecutive frames are stored in a window buffer. Ifthe current frame in the video stabilization process is frame i, thenthe buffered frames in the window can come from frames that are eithertemporally before (“look-ahead” window) or temporally after (“look-back”window) frame i.

Long-term (intentional) camera motion can be estimated by averaging outrandom camera vibration within the observation window. The window sizecan be adjusted to accommodate camera shakiness with differentfrequencies. Rotation radian values are generally small and so, in anembodiment, the window size is set to a power of two (e.g., eight, 16,or 64 frames), which simplifies the averaging calculation. Accuracy isimproved with a larger window size.

As unwanted (unintentional) camera vibration is generally short-term andrandom, it tends to be cancelled out when the average is done over along-enough duration. The size of the observation window can be adjustedto cope with vibrations at different frequencies. For example, to removesome low-frequency vibration, the window size can be increasedaccordingly so that the average is determined over a longer period oftime. On the other hand, for relatively high-frequency intentionalcamera motion, the window size can be reduced to preserve that motion.One strategy is to use input from a sensor on the device (such as agyro) to help automatically determine the window size. For example, ifthe sensor indicates that the device/camera is being moved at arelatively constant speed (e.g., intentional camera motion, such aspanning or zooming), then the window size can be reduced; and if thesensor indicates a movement characteristic of unintentional cameramotion (e.g., a sudden movement), then the window size can be increased.Other strategies for adjusting window size include adjusting the size inresponse to an input from a user or using information indicating how thecamera is being used (e.g., knowledge of the use scenario: the way thecamera is being used, or the type of events being captured).

The average motion associated with frame i can be calculated as thegeometric mean of the accumulated motions within each observationwindow:

$\begin{matrix}{{\overset{\_}{M}}_{i} = \sqrt[L]{\prod\limits_{i = 1}^{L}\; M_{i}}} & {{Eq}.\mspace{14mu} (1)}\end{matrix}$

where L is the size of the window. {tilde over (M)}_(i) can be regardedas the estimate of the long-term (stable) camera motion that occurredduring the observation window associated with frame i.

As the sliding observation window is moved over the input video frames,a series of locally estimated long-term camera motions are produced.However, due to the uncertain nature of the camera vibration, there maybe a residual random motion component in the estimate. Inaccurate GMEoutput due to occlusions, lack of feature points, etc., can also addambiguity to the estimate. Also, intentional camera motion can changeover time, so a local observation window may not perfectly capture thecamera's long-time motion all the time.

Kalman filtering is used in the present embodiments to mitigate suchuncertainties and produce more accurate intentional camera motionestimates. A Kalman filter consists of “predict” and “correct” stages.In the predict stage, the filter projects estimation statistics frompast-filtered samples to obtain an a priori estimate for the currentsample of frames: the state ahead is projected, and the error covarianceahead is projected. The a priori estimate effectively reduces noisesfrom GME.

In the correct stage of the Kalman filter, the measurement of thecurrent sample is taken into account to obtain an improved a posterioriestimate: the Kalman gain is computed, the projected state is updated,and the error covariance is updated. The filter's parameters also getupdated to propagate the estimation statistics to future samples.Because of the filter's recursive structure, these stages can beimplemented in an online processing manner and without storing anysample data.

In the present embodiments, Kalman filtering is applied to filter eachcoefficient individually in the transformation matrices {M _(i)} toproduce the smoothed version {{tilde over (M)}_(i)}. For a chosen motionmodel, each coefficient in M _(i) corresponds to a model coefficient. Asnoted above, Kalman filtering helps by predicting an a priori estimatebased on past filtered model coefficients to effectively reduce theimpact from residual random motion and GME noises contained in {M _(i)},and by incorporating the current M _(i) measurement into an a posterioriestimation of {tilde over (M)}_(i) to adapt to changes in any underlyingintentional camera motion.

In Kalman filtering, a pair of parameters Q (process noise covariance)and R (measurement noise covariance) controls the relative weightbetween the a priori estimate and the measurement value in the aposteriori estimation. Ideally, when there is less confidence about thecurrent global motion estimate M_(i), the Kalman filter will reduce theweight of the measurement value M _(i) to rely more on the past filteredsamples (the a priori estimate) when estimating {tilde over (M)}_(i). Inthe present embodiments, this is achieved as follows. In the GME module,after matching of blocks or feature points between two consecutive videoframes is performed, a list of matched coordinates are fed into theRANSAC (Random Sample Consensus) procedure to calculate modelcoefficients by minimizing RMSE (root mean square error). In that step,a number of coordinates may be rejected as outliers due to excessiveerrors. The ratio between the number of remaining inliers and the totalnumber of coordinates samples serves as a good indicator of thereliability of the derived global motion model; for example, a higherpercentage of inliers indicates a more reliable estimate, and viceversa. In an embodiment, this ratio is presented as a variable r in aheuristic equation to determine the relative weight between Q and R. Inone such embodiment, Q is to be a constant and R is adjusted accordingto:

R=(1−r)³×0.025  Eq. (2)

As just noted, Eq. (2) is heuristic and, in an embodiment, isconstrained such that a monotonically decreasing relationship between Rand r is maintained. A consequence of maintaining control over themeasurement weight is that the path optimizer can be more tolerant toGME noises. That in turn can help reduce the complexity of the GMEmodule 110 (FIG. 1), which is often the most complicated piece and thebottleneck in real time video stabilization.

In the Kalman filtering process, each estimated coefficient of themotion model is configured to be constant. As each filteredtransformation matrix {tilde over (M)}_(i) represents the relativeglobal motion between two consecutive frames i and i+1, that means theestimated intentional camera trajectory is modeled to be comprised ofpiecewise constant-speed (stable) motion, where constant speed includeszero motion. This conforms to cinematography rules so that thestabilized video is more pleasant to viewers.

After obtaining the intentional camera motion estimates {{tilde over(M)}_(i)}, the camera path optimization module 120 (FIG. 1) forms{{circumflex over (M)}_(i)} and uses it to warp the frame i. Astraightforward way to achieve this is to calculate the accumulatedmotion model {circumflex over (M)}_(i) for frame i as:

{circumflex over (M)} _(i)=√_(j=1) ^(i) {tilde over (M)} _(j).  Eq. (3)

However, that can lead to a “drifting” effect when the camera has aconsistent and perhaps intentional motion, such as panning, as shown inFIGS. 3A and 3B. In the present embodiments, a parameter F that may bereferred to herein as a “forgetting factor” (0≦F≦1) is introduced tomitigate the drifting effect. Specifically, in an embodiment, each modelcoefficient c from {circumflex over (M)}_(i) is updated to be c=(1−F)cbefore warping the frame i. Therefore, a larger value of F counters agreater drifting effect but may reduce the stabilizing power, and asmaller value of F can produce a more stabilized result but may losespatial resolution due to the drifting effect. The value of F can beleft to the users to decide depending on their preferences.

FIG. 4 is a flowchart 400 of an example of a computer-implemented methodfor video stabilization in embodiments according to the presentdisclosure. The operations of the flowchart 400 can be implemented bythe device 1200 of FIG. 12. For example, the operations of the flowchart400 can be implemented as computer-executable instructions residing onsome form of non-transitory computer-readable storage medium (e.g., thememory 1204 of FIG. 12) and executed by a processor (e.g., the processor1202 of FIG. 12).

In block 402 of FIG. 4, consecutive original video frames that arecaptured using a camera are buffered.

In block 404, global motion estimates {M_(i)} that describe the camera'srelative motion between two consecutive video frames are accessed.

In block 406, the geometric mean M _(i) of the global motion estimatesfor each of the subsets is determined (Eq. (1)).

In block 408, Kalman filtering is applied to the geometric mean for eachof the subsets to produce smoothed versions of the geometric means{{tilde over (M)}_(i)}.

In block 410, parameters (Q and R) of the Kalman filtering are adjustedaccording to an indicator of reliability of the global motion estimates.

In block 412, the smoothed versions of the geometric means aremultiplied (Eq. (3)) to determine the transformation matrices (theaccumulated motion model {circumflex over (M)}_(i)).

In block 414, coefficients of the transformation matrices are modified(e.g., by a forgetting factor F) to mitigate a drifting effectintroduced by multiplying the smoothed geometric means.

In block 416, the transformation matrices {{circumflex over (M)}_(i)}are used to warp the frames.

One-Pass Video Stabilization—Hybrid Model Localized Path Planning

In embodiments about to be described, a hybrid auto-corrective pathplanning approach that uses different models addresses artifacts causedby feature tracking due to rapid camera motion, occlusions, etc., andcaused by scene-dependent parameter tuning. Motion models are adaptivelyswitched according to the actual video.

The local camera path planning framework (FIG. 5) can generate anoptimized, visually pleasant camera trajectory according tocinematographic rules. The hybrid model stabilization approach cansignificantly improve stabilization results and reduce artifacts.Auto-corrective motion model switching can adaptively select and use thebest of the motion models according to the actual videos, which furtherhelps reduce artifacts. The overall framework can be implemented onsmartphones, tablets, etc., without parameter tuning, calibration, orother hardware support. Stabilization quality is improved, andcomputational cost is reduced.

FIG. 5 is a diagram illustrating overall workflow in a path planningframework in embodiments according to the present disclosure. In anembodiment, the path planning framework is implemented in the camerapath optimization module 120 of FIG. 1.

With reference to FIG. 5, the video capture thread A maintainsbackward-looking buffers 511 and 512 during the normal video capture,where an L-length video sequence is stored in the buffer. In addition, aforward-looking buffer could be utilized. Use of only a backward-lookingbuffer eliminates a potential source of delay in the overall systemoutput of the stabilized video.

The camera path planning thread B estimates the short-term cameratrajectory over the buffered video sequence (block 520) and computes thesmooth camera trajectory for stabilization (block 530). In anembodiment, a tree-splitting based approach is used, where hybrid motionmodels (block 540) are used for improved stabilization according tocinematographic rules.

To accommodate the large variety of video content and camera motionwhere it can be difficult to obtain satisfactory long feature tracks,and to reduce computational costs for real-time mobile applications,short-term fast feature tracking is used to obtain correspondencesbetween consecutive video frames. In other words, keypointcorrespondences are tracked during a short period of time, e.g., in twoconsecutive frames, using fast tracking methods. In an embodiment, thevery fast binary ORB (Oriented FAST [FIX Adapted for Streaming] andRotation BRIEF [Binary Robust Independent Elementary Features])keypoints are computed over each frame, which is approximately 20 timesfaster than computing SURF keypoints and 400 times faster than computingSIFT keypoints over an 1920×1080 HD (high definition) video.

To reduce the number of detected local points for robust and fasttracking, a grid-based mechanism can be used. In an embodiment, an imagegrid (e.g., 16×16) is used to spread the detected feature points intodifferent cells, and the strongest feature point having the highestresponse value is selected for each cell. This allows for more robustmotion estimation with lower complexity by reducing the number offeature points needed.

After feature point determination, feature point correspondences aredetermined between adjacent video frames in order to calculateinter-frame motion. A Kanade-Lucas-Tomasi (KLT) tracker is one exampleof an effective method to determine the feature point correspondences.Based on these correspondences, the inter-frame motion transformationmatrices (e.g., homography, affine, or similarity transformationmatrices) can be robustly estimated by using, for example, RANSAC andoutlier feature rejection techniques.

In the frame synthesis thread C of FIG. 5, a set of correctivetransformation matrices can be directly used to warp the original framesinto stabilized frames (block 550), which can then be displayed.

Consider a two-dimensional (2D) image point [u_(i),v_(i)]^(T) in animage x_(i) and a 2D image point [u_(j), v_(j)]^(T) in another imagex_(j). A three-by-three (3×3) homography H is generally used to relatethe pixel coordinates as:

[U _(J) ,V _(J),1]^(T) ˜H[U _(I) ,V _(I),1]^(T);

where “˜” means equal up to a scale, and therefore H has eight (8)degrees-of-freedom (8-DOF). When applied to every pixel, and withreference to FIG. 6, the image xj as a warped version of the image xi isobtained:

$\begin{matrix}{\begin{bmatrix}x_{j} \\y_{j} \\1\end{bmatrix} = {{H_{3 \times 3}\begin{bmatrix}x_{i} \\y_{i} \\1\end{bmatrix}}.}} & {{Eq}.\mspace{14mu} (4)}\end{matrix}$

Assuming linear projectivity, the 8-DOF homography can be reduced to a5-DOF affine transformation T. Assuming single rotation and isotropicscaling, the affine transformation T can be further reduced to a 4-DOFsimilarity transformation S. In general, models with higher DOFs aremore descriptive and are more powerful for stabilization. However,higher order models are more sensitive to errors in feature tracking andmotion estimation, and can generate more severe artifacts when sucherrors occur. In embodiments according to the present disclosure, ahybrid approach is used, in which the methodology automatically switchesamong 8-DOF homography, 5-DOF affine transformation, and 4-DOFsimilarity transformation, to adaptively improve stabilization resultsand reduce artifacts according to the actual video. In an embodiment,the mechanism for automatically determining an appropriate motion modelincludes an approach of gradually reducing the degree of freedom of themotion model based on a robustness test. Additional information isprovided below.

From a cinematographic standpoint, pleasant viewing experiences arerealized through the use of static cameras (e.g., a constant camerapath), panning cameras mounted on tripods, or cameras placed onto adolly (e.g., a camera path of constant velocity). Let W denote a 2Dtransformation matrix (W can be a homography H, affine transformation T,or similarity transformation S). The above cinematographiccharacteristics can be described as a camera path with a constanttransformation W, where a static camera can be represented by anidentity matrix W.

From fast feature tracking and motion estimation, a set of inter-frametransformation matrices {W^(i,i+1)} can be obtained over the bufferedL-length video sequence:

X _(i+1) =W ^(i,i+1) x _(i)  EQ. (5)

Based on cinematographic rules, a target video sequence that is stable,or as stable as possible, is desirable. Also, it is desirable tomaintain a reasonable field of view and avoid excessive skew andperspective artifacts. To achieve these goals, embodiments according tothe present disclosure determine a piecewise, constant-speed stablecamera path over the buffered L-length video sequence, where constantspeed also includes zero velocity. In an embodiment, the piecewisestable segments are determined using a tree-splitting method subject toa constraint for the out-of-bound area size and also subject to boundson the skewness of the warped frame. The tree-splitting method isdescribed further below.

The optimal constant transformation matrix W_(c) can be estimated over astable l-length piece or segment of camera path (1≦L) by optimizing thefollowing cost function:

min Σ_(i=1) ^(l) ∥x _(i+1) −W _(c) x _(i)∥².  EQ. (6)

Let y_(i) denote the target warped frame of an original frame x_(i);y_(i) will follow the optimized camera path:

y _(i+1) =W _(c) y _(i).  Eq. (7)

With reference to FIG. 7, a transformation matrix B^(i) that correctsthe original transformation matrix W^(i,i+1) (from Eq. (5)) to theoptimized transformation matrix W_(c) (from Eq. (6)) can be computed.The transformation matrix B^(i) is computed by: transforming the featurepoints of the current frame i by the original transformation W^(i,i+1),resulting in transformed feature points P^(i); transforming the featurepoints of the current frame i by the optimized transformation W_(c),resulting in transformed feature points P^(i) _(c); and computing B^(i)to align P^(i) with P^(i) _(c). B^(i) can be computed using the samemethod used to compute original W^(i,i+1), with the difference beingthat while W^(i,i+1) is computed using the original matching featurepoints from frames i and i+1, B^(i) is computed using the matchingfeature points P^(i) with P^(i) _(c). The corrective transformationmatrix B^(i) can warp the original frame x_(i) to generate the targetframe y_(i). The set of corrective transformation matrices {B^(i)} canbe directly used to warp the original frames into stabilized frames.

The process just described can be repeated to provide a stabilizedcamera path consisting of a series of stable segments as shown in FIG.8.

Then, given two segments of stable camera trajectory, a transitiontransformation W_(t) can be computed to smooth their transition. In anembodiment, the frames at the boundary of the two connecting segmentsare treated as a stable sub-segment, and feature correspondences ofthese frames are aggregated to compute another transformation matrixaround the transition area, which is used to rectify the transitionframes. Such a methodology keeps some level of transition inconsistencyas a tradeoff to avoid severe artifacts and to provide a larger field ofview. In an alternative implementation, one-pass real-time videostabilization can be performed by applying low-pass filters over localcamera trajectories, in combination with video-dependent parametertuning. The methodology can be enhanced to balance misalignmentartifacts, balance the field-of-view size, and balance the motioninconsistency in the transition areas by, for example, automaticallyadjusting the position and length of the transition boundary.

To divide the original L-length camera path into piecewise stablesegments, a fast tree-splitting method can be used to providelow-complexity processing in real time. To avoid severe skew andperspective artifacts, relatively tight bounds can be placed on theskewness of the warped frames. In an embodiment, the four corners of awarped frame are not allowed to deviate from the corresponding cornersof the previous warped frame by more than five percent. Also, the sizeof the accumulated out-of-bound area over a stable segment of camerapath is checked. In an embodiment, the compensated frames are set topreserve 80% of the original field of view. If these two constraints areviolated, then the corresponding segment of the camera path is split inhalf, and the optimized stable camera path is recomputed over each halfrespectively. The camera path segments can be recursively split in halfuntil one of these stop criteria is met: either all segments of thecamera path comply with the two constraints, or there are too few frames(e.g., less than a preset number) in an unsatisfactory segment tofurther split it.

When the tree-splitting path process stops, if unsatisfactory segmentsstill exist, then that indicates large artifacts exist in the warpedframes using the currently selected motion model. The artifacts may becaused by feature tracking failures due to abrupt large object/cameramotion or the lack of robust features. In such a case, the motion modelis reduced and a lower-DOF transformation is used instead. That is, thetree-splitting path planning described above is re-performed using alower-DOF transformation as W. Such a process can be repeated as thesystem gradually reduces the motion models until all camera piecessatisfy the criteria. If unsatisfactory segments still exist using thelowest-DOF motion model, then it indicates that large artifacts exist nomatter which motion model is used. To avoid unpleasant artifacts, thecorresponding frames in such portions of the video may not be processed;e.g., the original frames are preserved and the system gracefullydegrades over such frames.

FIGS. 9 and 10 are flowcharts 900 and 1000, respectively, of examples ofcomputer-implemented methods for video stabilization in embodimentsaccording to the present disclosure. The operations of the flowcharts900 and 1000 can be implemented by the device 1200 of FIG. 12. Forexample, the operations of the flowcharts 900 and 1000 can beimplemented as computer-executable instructions residing on some form ofnon-transitory computer-readable storage medium (e.g., the memory 1204of FIG. 12) and executed by a processor (e.g., the processor 1202 ofFIG. 12).

In block 902 of FIG. 9, a buffer is maintained during video capture. Thebuffer contains a set of original frames. The buffer may be abackward-looking buffer or a forward-looking buffer. Alternatively, botha backward-looking buffer and a forward-looking buffer may be used.

In block 904, a set of inter-frame motion models is used to obtain anoriginal camera trajectory over the buffered frames. In one embodiment,a set of keypoints in the original frames is extracted, the keypoints'correspondences between consecutive frames are computed, and a motiontransformation matrix between consecutive frames is computed.

In block 906, real-time localized camera path planning is performed toremove unintended uttering and shakiness from the original cameratrajectory. In one embodiment, a tree-splitting mechanism is used tofind a piecewise stable camera trajectory over the buffered frames, anda piece of stable camera trajectory is computed based on cinematographicrules. In one such embodiment, the tree-splitting mechanism uses aconstraint for the out-of-bound area size and a constraint for theskewness of the warped frame to determine the split location. In anothersuch embodiment, the segment of stable camera trajectory is computed bycomputing the segment of stable camera trajectory that mimics a staticcamera or a camera moving (e.g., panning or zooming) with constantvelocity.

In block 908, a camera trajectory is computed using an auto-correctivehybrid model. In one embodiment, the auto-corrective hybrid modelincludes a mechanism for automatically determining an appropriate motionmodel for the segment of stable camera trajectory. In one suchembodiment, the appropriate motion model is selected from the groupconsisting of: a homography, an affine transformation, and a similaritytransformation. In another such embodiment, the mechanism forautomatically determining an appropriate motion model includes anapproach of intelligently reducing the DOF of the motion model based ona robustness test. The robustness test may include testing whether thesegments of camera trajectories satisfy the constraint for theout-of-bound area size and the constraint for the skewness of the warpedframe as discussed above.

In block 910, a transitional camera trajectory is computed betweenconsecutive buffers. In one embodiment, the transitional cameratrajectory is computed by determining the position and length of thetransition boundary, and computing the transitional camera trajectoryusing the auto-corrective hybrid model.

In block 912, a set of stabilized frames is synthesized using the set oforiginal frames according to the computed camera trajectory.

In block 1002 of FIG. 10, a sliding window of consecutive original videoframes that are captured using a camera is buffered.

In block 1004, inter-frame transformation matrices {W^(i,i+1)} betweenpairs of consecutive frames in the first subset of the video frames aredetermined. The first subset may include all the frames in the slidingwindow, or a portion of those frames.

In block 1006, a first transformation matrix W_(c) for the first subsetof the subsets is generated (Eq. (6)) using a selected motion model(which may also be referred to herein as the first motion model). In anembodiment, the motion model is selected from a number of motion modelsincluding a homography model with eight degrees-of-freedom, an affinetransformation model with five degrees-of-freedom, and a similaritytransformation model with four degrees-of-freedom.

In block 1008, corrective transformation matrices {Bi} that change theinter-frame transformation matrices to match the first transformationmatrix are derived.

In block 1010, the corrective transformation matrices are applied to theoriginal video frames x_(i) in the first subset to determine the firstset of warped video frames y_(i).

In block 1012, a determination is made as to whether the first set ofwarped video frames satisfies one or more conditions. The conditionsinclude a constraint for out-of-bound area size and a constraint foramount of skewness of a warped video frame.

In block 1014, if the first set of warped video frames satisfies thecondition(s), then a second transformation matrix W_(c) for a secondsubset of the subsets is generated using the selected motion model;however, if the first set of warped video frames does not satisfy thecondition(s), then a determination is made as to whether the firstsubset can be divided into smaller subsets (block 1016).

In block 1018, if the first subset can be divided into smaller subsets,then it is divided into a second subset and a third subset, second andthird transformation matrices are generated for the second and thirdsubsets, respectively, using the selected motion model, and the secondand third transformation matrices are used to determine sets of warpedvideo frames from original video frames in the second and third subsets,respectively.

If, on the other hand, the first subset cannot be divided into smallersubsets, then a second (e.g., different and less complex) motion modelis selected (block 1020), a second transformation matrix for the firstsubset is generated using the second motion model, and the secondtransformation matrix may be used to determine the first set of warpedvideo frames.

More specifically, if the second motion model is selected because thecurrent (e.g., first) subset of video frames cannot be further divided,then blocks 1006, 1008, 1010, 1012, 1014, and 1018 are repeated usingthe second motion model in place of the first motion model. If, at block1018, after application of the second motion model, the current subsetcannot be further divided, then blocks 1006, 1008, 1010, 1012, 1014, and1018 may be repeated using a third motion model in place of the secondmotion model.

As mentioned above, the motion models may include a homography modelwith eight degrees-of-freedom, an affine transformation model with fivedegrees-of-freedom, and a similarity transformation model with fourdegrees-of-freedom. In the flowchart 1100, the first motion model mayrefer to the homography model, in which case the second motion model maybe the affine transformation model or the similarity transformationmodel; or the first motion model may refer to the affine transformationmodel, in which case the second motion model may refer to the similaritytransformation model.

To summarize, in the present embodiments just described, path planningis localized over buffered segments for real-time streaming instead ofover the whole camera trajectory, and multiple motion models for generalstabilization, where the system automatically switches models adaptivelyaccording to the actual videos, are used instead of using the similaritymodel for general stabilization and using homographies only intransition areas to alleviate misalignments.

The main computational cost of the methodology disclosed herein lies infeature tracking and frame synthesis. Camera path planning is generallyquite fast, since the computation is only over transformation matricesand point coordinates, which does not involve actual video frames.

In summary, according to the embodiments just described, auto-correctivehybrid model stabilization and localized camera path planning areintroduced. By automatically switching among different motion modelsaccording to the actual video, the disclosed invention can adaptivelychoose the optimal motion models to use and therefore can improvestabilization results as well as reduce unpleasant artifacts. Bymaintaining a backward-looking buffer and performing localized camerapath planning over the buffered video sequence, the disclosed inventionprovides one-pass real-time video stabilization ability, which bothfollows cinematographic rules to generate visually pleasant results andhas low complexity in order to be easily implemented on mobile devicesand the like. This is different from conventional two-pass stabilizersand conventional one-pass motion filtering approaches.

One-Pass Video Stabilization—Warping Frames by Global Motion Models

In embodiments about to be described, the GME module 110 (FIG. 1)receives or accesses shaky video frames, estimates the camera motion(“global motion”) between two consecutive frames, and outputs a modelthat describes the motion. In an embodiment, the GME module 110 consistsof two sub-steps: (1) global motion estimation; and (2) motion parameterestimation.

In the global motion estimation sub-step, block-based motion estimation(ME) is used to estimate a motion vector V(x, y) for each individualblock inside a frame. To reduce complexity, a diamond-search (DS-based)ME process is applied to 16×16 non-overlapping blocks by default.However, both the size of the blocks and the overlapping amount can beadjusted to other values. To further control complexity, when an inputvideo has a large resolution and/or high frame rate, each frame can bedown-sampled prior to ME without much compromise on performance. Forexample, a 720p/30 frames per second video can be down-sampled by halfin the spatial dimension.

In contrast to conventional DS-based ME procedures used in videocompression, in this sub-step, the objective is to determine “true”motion vectors (MVs) instead of “best” MVs in the rate-distortion sense.Therefore, during ME, some blocks are intentionally skipped where truemotions are difficult to estimate. In particular, a screening process isadded before the DS-based ME to exclude those blocks that are relativelyflat, e.g., have low texture variations. The screening process canimprove the consistency of the estimated motion fields.

To further reduce complexity, it is possible for the stabilizer to sharethe ME process if there exists an appropriate video encoder. Forexample, an x264 encoder may perform a quick 16×16 look-ahead ME to havea rough estimate of the motion statistics of incoming video frames inits pre-analysis stage. Accordingly, it is possible for the stabilizerto share the outcome of the x264's pre-analysis ME.

In the motion parameter estimation sub-step in GME, a motion model isestimated for each motion field constructed by the DS-based ME. Theestimated motion model captures how a frame moves due to camera motionrelative to its reference frame. In one or more embodiments, it may bepossible to exclude possible interference of “local” motions fromforeground objects in this step. To that end, a RANSAC robust estimatoris used. RANSAC iteratively samples a set of coordinate pairs from aframe pair and offset by its corresponding MV. The estimator then triesto estimate the best coefficients for a designated motion model bysolving a set of linear equations. In the process, MV outliers caused bylocal motions or imperfect ME can be automatically suppressed by RANSAC.

In one or more embodiments, a geometric model with four parameters isused to describe how the camera moves. Four parameters are adequate tocapture most types of motions caused by a shaky camera, and also toavoid extra fitting overhead and possibly ill-conditions associated withhigher-order models. Other models can be readily adopted within theframework of a stabilizer according to the present embodiments.

The derived geometric model takes the following form to map coordinate(x, y) to coordinate (x′, y′):

$\begin{matrix}{\begin{bmatrix}x^{\prime} \\y^{\prime}\end{bmatrix} = {{{\begin{bmatrix}a & {- b} \\b & a\end{bmatrix}\begin{bmatrix}x \\y\end{bmatrix}} + \begin{bmatrix}c \\d\end{bmatrix}} = {{r \cdot {\begin{bmatrix}{\cos \; \theta} & {{- \sin}\; \theta} \\{\sin \; \theta} & {\cos \; \theta}\end{bmatrix}\begin{bmatrix}x \\y\end{bmatrix}}} + {\begin{bmatrix}c \\d\end{bmatrix}.}}}} & {{Eq}.\mspace{14mu} (8)}\end{matrix}$

where a, b, c, and d are the model parameters, r=√{square root over(a²+b²)}, and θ=tan⁻¹(b/a). In its transformed form in the second halfof Eq. (8), the parameters r and θ represent the camera zooming androtation effects, respectively. The parameters c and d correspond tohorizontal and vertical movements of the camera. Therefore, camerajitters due to zooming, rotation and translations can be captured andstabilized.

The motion filtering receives or accesses motion statistics of the shakyvideo from GME, applies certain filtering operations to remove (orreduce) undesirable camera jitteriness, and outputs a smoothed motiontrajectory.

Camera shakiness to be removed is generally characterized as short-termmotion, and thus corresponds to the high-frequency components of acamera motion trajectory. By contrast, intentional camera motions (suchas panning, zooming, etc.) are regarded as long-term motion andcorrespond to the low-frequency portion. A goal of motion filtering isto eliminate high-frequency components but preserve low-frequency ones,effectively achieving the effect of filtering the motion trajectory witha low-pass filter.

In the present embodiments, a novel approach to motion filtering istaken. Denote M_(i) as the motion model that describes the relativeglobal motion between video frame f_(i−1) and f_(i):

$\begin{matrix}{\begin{bmatrix}x_{i - 1} \\y_{i - 1} \\1\end{bmatrix} = {{M_{i}\begin{bmatrix}x_{i} \\y_{i} \\1\end{bmatrix}} = {\begin{bmatrix}a & {- b} & c \\b & a & d \\0 & 0 & 1\end{bmatrix} \cdot \begin{bmatrix}x_{i} \\y_{i} \\1\end{bmatrix}}}} & {{Eq}.\mspace{14mu} (9)}\end{matrix}$

where (x_(i), y_(i)) is an arbitrary pixel coordinate from frame f_(i)and is mapped to pixel (x_(i−1), y_(i−1)) in frame f_(i−1) by M_(i). Inthe second half of Eq. (9), the geometric model of M_(i) is assumed tobe as in Eq. (8). In an embodiment, all the coefficients of M_(i) areobtained from the previous GME step.

Furthermore, denote {tilde over (M)}_(i) ^(j) as the accumulated motionbetween frames, defined as:

{tilde over (M)} _(i) ^(j) =M _(i) ·M _(i+1) . . . M _(j)=Π_(k=i) ^(j) M_(k).  Eq. (10)

{tilde over (M)}_(i) ^(j) then describes the relative global motionbetween frames f_(i) and f_(j) (i<j). Apply {tilde over (M)}_(i) ^(j) tof_(j):

{circumflex over (f)} _(i) ={tilde over (M)} _(i) ^(j)(f _(i)).  Eq.(11)

In Eq. (11), every pixel coordinate from f_(i) is mapped by {tilde over(M)}_(i) ^(j) as in Eq. (9), the resulting transformed frame {circumflexover (f)}_(i) will be temporally aligned with f_(i), so that therelative global motion due to camera motion between the two frames iseliminated.

Eq. (11) can be repeatedly applied to any input frame f_(j) (with f_(i)set to be the first frame f₀ of the video) to obtain a stabilized video.However, this may not be possible if, for example, there is anylong-term intentional camera motion in the video, since the intentionalcamera motion may be accumulated by {tilde over (M)}_(i) ^(j) and causetransformed frames to “drift” gradually, even eventually out of theframe boundary. Here, “drift” is referred to in a general sense in thatit includes not only translational moves, but also zooming in/out androtations.

As previously described, FIGS. 3A and 3B show a pair of frames takenfrom the middle of a video that has a consistent camera panning to theright; FIG. 3A is the original frame, and FIG. 3B is the transformedframe according to Eqs. (10) and (11). As depicted, the right frame'scontent is shifted to the right due to the accumulated panning motion,thus leaving an area of the frame with unfilled black pixels.

The present embodiments according to the invention provide a mechanismto counter the drift effect. In one or more embodiments, a mechanism isprovided to detect and then compensate a long-term, consistent motion.In an embodiment, an observation window is associated with each frame,as shown in FIG. 2 previously described herein, from which the motioncharacteristics in a period can be determined. In FIG. 2, the currentframe in the stabilization process is frame i and the observation windowcan include preceding frames (“look-ahead”) or following frames(“look-back”) in temporal order.

To detect drift, it is assumed that, for a long-term camera motion, theaccumulated motion in the observation window should be more substantialcompared to any short-term random camera motion that also might occur inthe same window, as long as the window size is large enough.

For example, using the look-ahead window in FIG. 2 to detect a long-termcamera motion at frame i, all the motion models M_(i+1), M_(i+2), . . ., M_(i+k) in the look-ahead window are accumulated in the variable{tilde over (M)}_(i+1) ^(i+k) and its geometric mean M is calculated:

{tilde over (M)} _(i+1) ^(i+k) =M _(i+1) ·M _(i+2) · . . . ·M _(i+k)=( M)^(k).  Eq. (12)

If {tilde over (M)}_(i+1) ^(i+k) is significant, so is M. Hence, M istested against a set of thresholds:

r( M )<r _(low) or r( M )>r _(high)

|θ( M )|>θ_(thresh) or |c( M )|>c _(thresh) or |d( M )|>d _(thresh)  Eq.(13)

where r(M), θ(M), c(M), and d(M) follow their respective definitions inEq. (8) (but in terms of M) and the right-side variables in the aboveinequalities are predefined threshold values.

If M passes any of the tests, a long-term, consistent camera motion isdeclared. When a long-term camera motion detected, as the next step, itseffect is removed from the accumulation process. As the geometric mean,M represents a smoothed, averaged version of the long-term motionsoccurring in the observation window. The long-term effect is negatedfrom the current motion model M_(i) by:

r(M _(i))=r(M _(i) /M ),θ(M _(i))=θ(M ₁)−θ( M ),c(M ₁)=c(M _(i))−c( M)d(M _(i))=d(M _(i))−d( M ).  Eq. (14)

After application of Eq. (14), the adjusted M_(i) is accumulated in{tilde over (M)}_(i) that later warps frame f_(i).

From the above steps, if the threshold values in Eq. (13) are set tooloose (or large) compared to the real motion experienced by the camera,some long-term motions with small magnitudes may fail to be detected andthus get accumulated in {tilde over (M)}_(i) ^(j). These motions cangradually cause stabilized frames to drift and leave more areas in blackpixels. On the other hand, if these values are set too restrictive (orsmall), the current motion model M_(i) may get adjusted by non-zeroaccumulated camera body disturbance, which may lead to a less stabilizedvideo. In practice, these threshold values can be automatically adaptedaccording to detected camera motions. For example, when the modeledmotion parameters in Eq. (8) consistently exceed the set of thresholdvalues in Eq. (13), those values can be adjusted upwards, and viceversa.

In Eq. (12), there is an observation window that stores a number ofmotion models to detect long-term camera motions. The window can be setto store models from either future or past frames (relative to thecurrent video frame). When storing the future models, any long-termmotion can be learned in advance before it gets accumulated in {tildeover (M)}_(i+1) ^(i+k) so it generally produces smaller unfilled areas.In one or more embodiments, past models may be stored. According tothese embodiments, a stabilized video frame in sync with the input framethat does not require extra frame storage can be output.

In one or more of the present embodiments, the frame synthesizer modulereceives or accesses smoothed motion models from motion filtering andapplies them to warp the corresponding original video frames, andoutputs stabilized (and possibly further processed) video frames.

There may still exist residual drifts in the process that cause blackboundaries around frames of a stabilized video. An optional trimmingstep can be applied to remove them. To do that, the stabilizer accordingto the present embodiments can record the largest trimming ratio of allthe transformed frames. Meanwhile, the stabilizer also stores eachstabilized frame. Once the normal stabilization is done, the storedvideo file is rescanned and unfilled regions are cropped away.

A flowchart 1100 of a method of video stabilization according to thepresent embodiments is shown in FIG. 11. The operations of the flowchart1100 can be implemented by the device 1200 of FIG. 12. For example, theoperations of the flowchart 1100 can be implemented ascomputer-executable instructions residing on some form of non-transitorycomputer-readable storage medium (e.g., the memory 1204 of FIG. 12) andexecuted by a processor (e.g., the processor 1202 of FIG. 12).

In block 1102 of FIG. 11, input video frames are accessed. In block1104, a block-based GME model is estimated, to estimate a motion vectorfor each individual block inside a frame. In block 1106, motion modelingfiltering is performed using, for example, a RANSAC estimator, tosuppress motion vector outliers or imperfect motion estimation. In block1108, a motion model that describes the relative global motion betweentwo consecutive frames is produced (Eqs. (9), (10), (11)), and thosemotion models are stored (e.g., buffered) in memory.

The following blocks in the flowchart 1100 are performed for each frameto be processed. In block 1110, the motion model for the frame beingprocessed is retrieved from memory. In block 1112, the motion models forneighboring frames are retrieved from memory. In block 1114, thegeometric mean of the motion models for the neighboring frames iscalculated (Eq. (12)).

In block 1116, using the geometric mean of block 1114, a determinationis made with regard to whether there is long-term motion present (Eq.(13)). If not, then the flowchart 1100 proceeds to block 1120. If so,then the flowchart 1100 proceeds to block 1118. In block 1118, thelong-term motion is negated from the motion model for the frame beingprocessed (Eq. (14)).

In block 1120, the motion model for the frame being processed isaccumulated in {tilde over (M)}_(i). In block 1122, {tilde over (M)}_(i)is used to warp the frame currently being processed.

FIG. 12 is a block diagram of an example of a device 1200 capable ofimplementing embodiments according to the present invention. The device1200 broadly represents any single or multi-processor computing deviceor system capable of executing computer-readable instructions. Thedevice 1200 can be used to implement the video stabilizationfunctionality disclosed herein. Depending on the implementation, thedevice 1200 may not include all of the elements shown in FIG. 12, and/orit may include elements in addition to those shown in FIG. 12. Thedevice 1200 may be a mobile device, such as but not limited to asmartphone, tablet, or wearable device such as glasses and a watch.

In its most basic configuration, the device 1200 may include at leastone processor 1202 (CPU) and at least one memory 1204. The processor1202 generally represents any type or form of processing unit capable ofprocessing data or interpreting and executing instructions. In certainembodiments, the processor 1202 may receive instructions from a softwareapplication or module (e.g., the video stabilization application/module)stored in a memory (e.g., the memory 1204). These instructions may causethe processor 1202 to perform the functions of one or more of theexample embodiments described and/or illustrated herein.

The memory 1204 generally represents any type or form of volatile ornon-volatile storage device or medium capable of storing data and/orother computer-readable instructions (e.g., a video stabilizationapplication/module). In certain embodiments the device 1200 may includeboth a volatile memory unit (such as, for example, the memory 1204) anda non-volatile storage device (not shown).

The device 1200 may include a display device 1206 that is operativelycoupled to the processor 1202. The display device 1206 is generallyconfigured to display a graphical user interface (GUI) that provides aneasy to use interface between a user and the device.

The device 1200 may also include an input device 1208 that isoperatively coupled to the processor 1202. The input device 1208 mayinclude a touch sensing device (a touch screen) configured to receiveinput from a user's touch and to send this information to the processor1202. The input device 1208 may be integrated with the display device1206 or they may be separate components. The input device 1208 anddisplay device 1206 may be collectively referred to herein as a touchscreen display 1207.

The device 1200 may also include a camera 1212 that can be used tocapture single images and video sequences.

The device 1200 may also employ any number of software, firmware, and/orhardware configurations. For example, the example embodiments disclosedherein may be encoded as a computer program (also referred to ascomputer software, software applications, computer-readableinstructions, or computer control logic) on a computer-readable medium.

The computer-readable medium containing the computer program may beloaded into the device 1200. All or a portion of the computer programstored on the computer-readable medium may then be stored in the memory1204. When executed by the processor 1202, a computer program loadedinto the device 1200 may cause the processor 1202 to perform and/or be ameans for performing the functions of the example embodiments describedand/or illustrated herein. Additionally or alternatively, the exampleembodiments described and/or illustrated herein may be implemented infirmware and/or hardware.

Although the subject matter has been described in language specific tostructural features and/or methodological acts, it is to be understoodthat the subject matter defined in the disclosure is not necessarilylimited to the specific features or acts described above. Rather, thespecific features and acts described above are disclosed as exampleforms of implementing the disclosed invention.

Embodiments according to the invention are thus described. While thepresent disclosure has been described in particular embodiments, itshould be appreciated that the invention should not be construed aslimited by such embodiments, but rather construed according to the belowclaims.

While several embodiments have been provided in the present disclosure,it should be understood that the disclosed systems and methods might beembodied in many other specific forms without departing from the spiritor scope of the present disclosure. The present examples are to beconsidered as illustrative and not restrictive, and the intention is notto be limited to the details given herein. For example, the variouselements or components may be combined or integrated in another systemor certain features may be omitted, or not implemented.

In addition, techniques, systems, subsystems, and methods described andillustrated in the various embodiments as discrete or separate may becombined or integrated with other systems, modules, techniques, ormethods without departing from the scope of the present disclosure.Other items shown or discussed as coupled or directly coupled orcommunicating with each other may be indirectly coupled or communicatingthrough some interface, device, or intermediate component whetherelectrically, mechanically, or otherwise. Other examples of changes,substitutions, and alterations are ascertainable by one skilled in theart and could be made without departing from the spirit and scopedisclosed herein.

What is claimed is:
 1. A device configured to provide one-pass,real-time video stabilization, comprising: a memory including a bufferand instructions; and a processor coupled to the memory, the processorconfigured to execute the instructions stored in the memory to cause theprocessor to: store consecutive video frames in the buffer of the memoryafter receipt, the consecutive video frames including a current videoframe and previous video frames; estimate a global motion for thecurrent video frame by describing a camera's relative motion between thecurrent video frame and one of the previous video frames adjacent to thecurrent video frame; estimate a long-term camera motion for the currentvideo frame by determining a geometric mean of an accumulation of theestimated global motion for the current video frame and an estimate ofglobal motion for each of the previous video frames; and stabilize thecurrent video frame based on the estimated long-term camera motion; anda display device coupled to the processor, the display device configuredto display the current video frame as stabilized.
 2. The device of claim1, wherein the instructions when executed further cause the processor toapply a Kalman filter to smooth the estimated long-term camera motion.3. The device of claim 2, wherein the estimated global motion for thecurrent video frame comprises a first transformation matrix, theestimated long-term camera motion for the current video frame comprisesa second transformation matrix, and the smoothed estimated long-termcamera motion is a third transformation matrix.
 4. The device of claim3, wherein the first transformation matrix, the second transformationmatrix, and the third transformation matrix each comprise a N×N matrix.5. The device of claim 1, wherein the current video frame is warpedprior to being displayed.
 6. The device of claim 5, wherein theinstructions when executed further cause the processor to, prior towarping the current video frame, adjust the estimated long-term cameramotion according to the formula:c=(1−F)×c wherein c is a coefficient of the estimated long-term cameramotion and F is a forgetting factor between 0 and
 1. 7. The device ofclaim 1, wherein the instructions when executed further cause theprocessor to: match a plurality of feature points between the currentvideo frame and the one of the previous video frames adjacent to thecurrent video frame; calculate a ratio between a number of inlierfeature points and a total number of feature points; and determine aprocess noise covariance parameter and a measurement noise covarianceparameter using the ratio, the process noise covariance parameter andthe measurement noise covariance parameter used by a Kalman filter tocontrol a relative weight between an a priori estimation and ameasurement value in an a posteriori estimation.
 8. The device of claim1, wherein the instructions when executed further cause the processor toadjust a number of video frames in a subset of the consecutive videoframes in response to one or more of an input from a sensor on thedevice, an input from a user, and information indicating how the deviceis being used.
 9. The device of claim 1, wherein the buffer comprisesone of a window buffer, a backward-looking buffer, and a forward-lookingbuffer.
 10. A method of stabilizing a video in real time using a singlepass, comprising: receiving consecutive video frames, the consecutivevideo frames including a current video frame and previous video frames;storing the consecutive video frames in a buffer; estimating a globalmotion for the current video frame by describing a camera's relativemotion between the current video frame and one of the previous videoframes adjacent to the current video frame; estimating a long-termcamera motion for the current video frame by determining a geometricmean of an accumulation of the estimated global motion for the currentvideo frame and an estimate of global motion for each of the previousvideo frames; and displaying the current video frame on a display of anelectronic device, the current video frame stabilized based on theestimated long-term camera motion.
 11. The method of claim 10, furthercomprising applying a Kalman filter to the estimated long-term cameramotion to smooth the estimated long-term camera motion.
 12. The methodof claim 11, wherein the estimated global motion for the current videoframe comprises a first transformation matrix, the estimated long-termcamera motion for the current video frame comprises a secondtransformation matrix, and the smoothed estimated long-term cameramotion is a third transformation matrix.
 13. The method of claim 12,wherein the first transformation matrix, the second transformationmatrix, and the third transformation matrix each comprise a N×N matrix.14. The method of claim 10, further comprising warping the current videoframe according to the estimated long-term camera motion for the currentvideo frame.
 15. The method of claim 14, wherein, prior to warping thecurrent video frame, the method further comprises adjusting theestimated long-term camera motion according to the formula:c=(1−F)×c wherein c is a coefficient of the estimated long-term cameramotion and F is a forgetting factor between 0 and
 1. 16. The method ofclaim 10, further comprising matching a plurality of feature pointsbetween the current video frame and the one of the previous video framesadjacent to the current video frame; calculating a ratio between anumber of inlier feature points and a total number of the plurality offeature points; and determining a process noise covariance parameter anda measurement noise covariance parameter with the ratio, the processnoise covariance parameter and the measurement noise covarianceparameter used by a Kalman filter to control a relative weight betweenan a priori estimation and a measurement value in an a posterioriestimation.
 17. The method of claim 13, wherein the buffer comprises awindow buffer.
 18. The method of claim 13, wherein the buffer comprisesone of a backward-looking buffer and a forward-looking buffer.
 19. Acomputer program product comprising computer executable instructionsstored on a non-transitory medium that when executed by a processorcause a one-pass, real-time video stabilization device to: receiveconsecutive video frames, the consecutive video frames including acurrent video frame and previous video frames; store the consecutivevideo frames in a buffer; estimate a global motion for the current videoframe by describing a camera's relative motion between the current videoframe and one of the previous video frames adjacent to the current videoframe; estimate a long-term camera motion for the current video frame bydetermining a geometric mean of an accumulation of the estimated globalmotion for the current video frame and an estimate of global motion foreach of the previous video frames; and display the current video frameon a display of an electronic device, the current video frame stabilizedbased on the estimated long-term camera motion.
 20. The computer programproduct of claim 19, wherein the estimated global motion for the currentvideo frame comprises a first transformation matrix, the estimatedlong-term camera motion for the current video frame comprises a secondtransformation matrix, and the smoothed estimated long-term cameramotion is a third transformation matrix, and wherein the buffercomprises one of a window buffer, a backward-looking buffer, and aforward-looking buffer.